<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE HTML>
<html>
<head>
    <meta charset="utf-8">
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
    <meta http-equiv="Cache-Control" content="no-siteapp" />
    <!--[if lt IE 9]>
    <script type="text/javascript" src="lib/html5shiv.js"></script>
    <script type="text/javascript" src="lib/respond.min.js"></script>
    <![endif]-->
    <link rel="stylesheet" type="text/css" href="static/h-ui/css/H-ui.min.css" />
    <link rel="stylesheet" type="text/css" href="static/h-ui.admin/css/H-ui.admin.css" />
    <link rel="stylesheet" type="text/css" href="lib/Hui-iconfont/1.0.8/iconfont.css" />
    <link rel="stylesheet" type="text/css" href="static/h-ui.admin/skin/default/skin.css" id="skin" />
    <link rel="stylesheet" type="text/css" href="static/h-ui.admin/css/style.css" />
    <!--[if IE 6]>
    <script type="text/javascript" src="lib/DD_belatedPNG_0.0.8a-min.js" ></script>
    <script>DD_belatedPNG.fix('*');</script>
    <![endif]-->
    <script type="text/javascript" src="lib/jquery/1.9.1/jquery.min.js"></script>
    <script type="text/javascript" src="lib/layer/2.4/layer.js"></script>
    <script type="text/javascript" src="lib/My97DatePicker/4.8/WdatePicker.js"></script>
    <script type="text/javascript" src="static/h-ui/js/H-ui.min.js"></script>
    <script type="text/javascript" src="static/h-ui.admin/js/H-ui.admin.js"></script>
    <title>订单统计</title>
    <style>
        .table>tbody>tr>td{
            text-align:center;
        }
    </style>
</head>
<body>
<nav class="breadcrumb"><i class="Hui-iconfont">&#xe67f;</i> 首页 <span class="c-gray en">&gt;</span> 统计报表 <span class="c-gray en">&gt;</span> 商品销量报表 <a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px" href="javascript:location.replace(location.href);" title="刷新" ><i class="Hui-iconfont">&#xe68f;</i></a></nav>
<div class="page-container" >
    <form id="form-search">
    <div class="cl pd-5 bg-1 bk-gray mt-20" style="margin-top: 0px;">
		<span class="l">

			&nbsp;&nbsp;时间范围：
            <input type="text" onfocus="WdatePicker({ maxDate:'#F{$dp.$D(\'endDate\')}',dateFmt:'yyyy-MM-dd' })" id="startDate" name="startDate" class="input-text Wdate" style="width:160px;">
            -
            <input type="text" onfocus="WdatePicker({ minDate:'#F{$dp.$D(\'startDate\')}',dateFmt:'yyyy-MM-dd' })" id="endDate" name="endDate" class="input-text Wdate" style="width:160px;">
			&nbsp;&nbsp;<button id="searchButton" type="submit" class="btn btn-success">确定</button>
		</span>
    </div>
    <div class="cl pd-5 bg-1 bk-gray mt-20">
        <span class="l">
            <a href="javascript:;" onclick="exportData();" class="btn btn-primary radius"><i class="Hui-iconfont">&#xe640;</i> 导出报表</a>
        </span>
    </div>
    </form>
    <div class="mt-20">
        <div class="mt-20" style="margin-bottom: 70px">
            <table class="table table-border table-bordered table-bg table-hover table-sort" width="100%">
                <thead>
                <tr class="text-c">
                    <th width="500">商品名称</th>
                    <th width="500">销售数量</th>
                    <th width="500">销售金额</th>
                </tr>
                </thead>
            </table>
        </div>
    </div>

</div>


<!--请在下方写此页面业务相关的脚本-->
<script type="text/javascript" src="lib/datatables/1.10.0/jquery.dataTables.min.js"></script>
<script type="text/javascript" src="lib/datatables/dataTables.colReorder.min.js"></script>
<script type="text/javascript" src="lib/laypage/1.2/laypage.js"></script>
<script type="text/javascript" src="lib/jquery.validation/1.14.0/jquery.validate.js"></script>
<script type="text/javascript" src="lib/jquery.validation/1.14.0/validate-methods.js"></script>
<script type="text/javascript" src="lib/common.js"></script>
<script type="text/javascript">

    $(function () {
        $('.table').DataTable({
            "processing": true,//加载显示提示
            "ajax": {
                url:"/order/salesStatistic",
                type: 'GET'
            },
            "columns": [
                { "data": "itemTitle"},
                { "data": "saleNum"},
                { "data": "saleAmount"}
            ],
            "aaSorting": [[ 2, "desc" ]],//默认第几个排序
            "bStateSave": false,//状态保存
            "aoColumnDefs": [
                {"orderable":false,"aTargets":[0]}// 制定列不参与排序
            ],
            language: {
                url: '/lib/datatables/Chinese.json'
            },
            colReorder: true
        });
    })

    $("#form-search").validate({
        onkeyup:false,
        focusCleanup:false,
        success:"valid",
        submitHandler:function(form){
            var startTime= $('#startDate').val();
            var endTime= $('#endDate').val();
            var param = {
                "startTime": startTime,
                "endTime": endTime
            };
            var table = $('.table').DataTable();
            table.settings()[0].ajax.data = param;
            console.log(table.settings()[0].ajax.data);
            table.ajax.url( '/order/salesStatistic' ).load();
        }
    });

    function exportData() {
        var startTime= $('#startDate').val();
        var endTime= $('#endDate').val();
        window.open("/order/exportSalesStatistic?startTime="+startTime + "&endTime="+endTime);
    }

</script>
</body>
</html>